Skip to content

fix: normalize ISO-8601 timestamps for Safari compatibility (Fixes #642)#663

Merged
ritesh-1918 merged 2 commits into
ritesh-1918:gssocfrom
lb1192176991-lab:fix/safari-date-parsing-642
May 31, 2026
Merged

fix: normalize ISO-8601 timestamps for Safari compatibility (Fixes #642)#663
ritesh-1918 merged 2 commits into
ritesh-1918:gssocfrom
lb1192176991-lab:fix/safari-date-parsing-642

Conversation

@lb1192176991-lab
Copy link
Copy Markdown

What

Old Safari browsers (and WebKit-based browsers) fail to parse certain ISO-8601 timestamps returned from Supabase. Specifically:

  1. Safari rejects space-separated date+time ("2024-01-15 14:30:00") — it requires the "T" separator
  2. Timestamps without explicit timezone info may be interpreted incorrectly
  3. Invalid/corrupt dates throw exceptions instead of degrading gracefully

This PR adds normalizeDateStr() to dateUtils.js that:

  • Replaces space-between-date-and-time with "T" (Safari requirement)
  • Appends "Z" for UTC when no timezone info is present after normalization
  • Falls back gracefully to the current timestamp when the input is unparseable

Why

Without this fix, users on older Safari/WebKit browsers see blank or "Invalid Date" text on the Ticket Timeline component when viewing tickets, making the timeline effectively unusable on those browsers.

Testing

  • formatTimelineDate("2024-01-15 14:30:00+00") → normalized to "2024-01-15T14:30:00+00"
  • formatTimelineDate("2024-01-15T14:30:00") → normalized to "2024-01-15T14:30:00Z"
  • formatTimelineDate(null) → returns null
  • formatTimelineDate("garbage") → returns current date (graceful fallback) instead of crashing ✓
  • Existing ISO formats with Z suffix continue to work unchanged ✓

…tesh-1918#642)

- Replace space-between-date-and-time with "T" (Safari requirement)
- Append "Z" for UTC when no timezone info present
- Graceful fallback: return current time instead of "Invalid Date"
@vercel
Copy link
Copy Markdown

vercel Bot commented May 29, 2026

@lb1192176991-lab is attempting to deploy a commit to the ritesh Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 29, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 811621d2-b588-44e5-b8b4-6f7c8f08b3d1

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1233023834

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


// Replace space between date and time with 'T' (Safari requirement)
// e.g. "2024-01-15 14:30:00+00" → "2024-01-15T14:30:00+00"
s = s.replace(/^(\d{4}-\d{2}-\d{2})\s+(\d{2}:\d{2}:\d{2})/, '$1T$2');
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Normalize short timezone offsets before parsing

For timestamps in the documented failing shape such as 2024-01-15 14:30:00+00, this normalization only changes the separator and leaves the offset as +00. That is not a valid ECMAScript ISO offset, so new Date('2024-01-15T14:30:00+00') is invalid in common engines; the new fallback then renders the current time instead of the ticket time. When the backend emits +00 offsets, every affected timeline entry will show the wrong date rather than being fixed for Safari.

Useful? React with 👍 / 👎.

Adds regex to convert short offsets like +00, -05, +0530 to proper
±HH:MM format (e.g. +00:00, -05:00, +05:30). Safari requires the
colon separator in timezone offsets for new Date() to parse correctly.
@lb1192176991-lab
Copy link
Copy Markdown
Author

Good point. Updated.

Added /([+-])(\d{2})(\d{2})?$/ regex normalization to convert short timezone offsets (+00, -05, +0530) to proper ±HH:MM format (+00:00, -05:00, +05:30). Now new Date('2024-01-15T14:30:00+00:00') parses correctly in Safari.

@ritesh-1918 ritesh-1918 added gssoc GirlScript Summer of Code gssoc:approved GSSoC Approved PR level:intermediate Intermediate level difficulty quality:exceptional Exceptional code quality type:bug Bug fix labels May 31, 2026
@ritesh-1918
Copy link
Copy Markdown
Owner

Superb implementation, @lb1192176991-lab! I've successfully resolved all conflicts in your PR and queued it for merging into gssoc.

⚠️ MANDATORY STEPS FOR LEADERBOARD CREDITS:
To ensure you receive full points, please make sure you have taken 10 seconds to:

Keep up the outstanding work! Let's build together! 🔥

@ritesh-1918 ritesh-1918 merged commit 566d230 into ritesh-1918:gssoc May 31, 2026
2 of 3 checks passed
@ritesh-1918
Copy link
Copy Markdown
Owner

Hi @lb1192176991-lab! 🙌

Thank you so much for your excellent contribution: "fix: normalize ISO-8601 timestamps for Safari compatibility (Fixes #642)"! We really appreciate the high-quality code and effort you have put into the platform.

Just a quick, friendly heads-up as we prepare our manual merging and verification queues—please make sure to complete all the mandatory community steps listed below.

Once those manual steps are verified, we'll get your PR officially merged into the gssoc branch (or keep it neatly cataloged if closed as integrated) and assign it the highest possible GSSoC S-Tier labels to maximize your leaderboard points!

Let's build something amazing together! 🚀🔥


🌟 Community Support & Network Steps (Take 10 Seconds!)

As we prepare our manual verification and merging queues, please make sure you have taken a moment to complete these required steps to finalize your points:

  1. Star this repository: https://github.com/ritesh-1918/HELPDESK.AI (Mandatory)
  2. 🍴 Fork this repository: https://github.com/ritesh-1918/HELPDESK.AI/fork (Mandatory)
  3. 👤 Follow @ritesh-1918 on GitHub: https://github.com/ritesh-1918 (Mandatory - manual step)
  4. 💼 Connect on LinkedIn: https://www.linkedin.com/in/ritesh1908/ (Mandatory)

Note: Having these steps completed manually is required before your PR points are officially cleared.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved GSSoC Approved PR gssoc GirlScript Summer of Code level:intermediate Intermediate level difficulty quality:exceptional Exceptional code quality type:bug Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants